package com.itheima.homework05;

import java.math.BigDecimal;
import java.util.ArrayList;

public class Test {
    public static void main(String[] args) {
        Student stu1=new Student("张三","男",20,79.5);
        Student stu2=new Student("李四","男",21,80.2);
        Student stu3=new Student("王五","男",22,77.9);
        Student stu4=new Student("周六","男",20,55.8);
        Student stu5=new Student("赵七","男",21,99.9);
        ArrayList<Student> list=new ArrayList<>();
       list.add(stu1);
       list.add(stu2);
       list.add(stu3);
       list.add(stu4);
       list.add(stu5);
       double sum=0.0;
        for (int i = 0; i < list.size(); i++) {
            sum+=list.get(i).getScore();
        }
        BigDecimal b1=new BigDecimal(sum);
        BigDecimal b2=new BigDecimal(list.size());
        System.out.println("平均值："+b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP));
    }
}
